/**
 * Invoice 业务逻辑实现类
 * @author zhangq
 * @date 2015-03-09
 */
package com.chnbst.bstyun.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.Invoice;
import com.chnbst.bstyun.model.vo.InvoiceVo;
import com.chnbst.bstyun.service.InvoiceService;

@Transactional
@Service
public class InvoiceServiceImpl extends BaseService implements InvoiceService {
	
	//声明命名空间
	private final static String nameSpace = "com.chnbst.bstyun.mapper.InvoiceMapper";

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertInvoice(Invoice invoice) {
		return DaoHelper.insert(nameSpace, "insertInvoice", invoice);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean deleteInvoice(Integer invoiceId) {
		return DaoHelper.delete(nameSpace, "deleteInvoice", invoiceId);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean updateInvoice(Invoice invoice) {
		return DaoHelper.update(nameSpace, "updateInvoice", invoice);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Invoice selectInvoice(Integer invoiceId) {
		return (Invoice)DaoHelper.query(nameSpace, "selectInvoice", invoiceId);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<InvoiceVo> selectInvoiceList(Map<String, Object> map) {
		return (List<InvoiceVo>)DaoHelper.list(nameSpace, "selectInvoiceList", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public InvoiceVo selectInvoiceVo(Integer invoiceId) {
		return (InvoiceVo)DaoHelper.query(nameSpace, "selectInvoiceVo", invoiceId);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public int selectInvoiceCount(Map<String, Object> map) {
		return DaoHelper.count(nameSpace, "selectInvoiceCount", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@SuppressWarnings("unchecked")
	@Override
	public List<InvoiceVo> selectInvoiceVos(Map<String, Object> map) {
		return (List<InvoiceVo>)DaoHelper.list(nameSpace, "selectInvoiceVos", map);
	}
}